import numpy as np 
import os
import keras
from tqdm import tqdm
from net1 import *

from matplotlib import pyplot as plt 
from keras.optimizers import *
from keras import optimizers
#from keras.models import load_weights
from keras.models import *
from keras.callbacks import ModelCheckpoint, LearningRateScheduler
from keras.utils.multi_gpu_utils import multi_gpu_model
import time
import scipy.io as sio
import numpy as np

os.environ["CUDA_VISIBLE_DEVICES"] = "3"

time_s = time.perf_counter()

inputdata = np.load('./input/data_0021.npy')
inputdata = np.reshape(inputdata, [1,64,64,64,32])
# label = np.load('label1.npy')  
time_e = time.perf_counter()

print('input shape is: ', inputdata.shape)
# print(label.shape)
print(time_e-time_s)


#train
Model = unet()
Model.load_weights('model/pattern_NormTo1_rand0021TO0100_0221TO0300_labelGauss_DLR_Init8EN4_Epoch50TO0.5_LossMSE-E200.hdf5')
Result = Model.predict(inputdata)
print('result shape is: ', Result.shape)
np.save('./predict/pred_0021.npy', Result)

# for nfile in range(10):
# 	print(nfile)
# 	pred_name = './predict/pred_' + str(nfile+1).rjust(4, '0') + '.npy'
# 	print(pred_name)
# 	Predict = np.squeeze(Result[nfile, :, :, :, :])
# 	print(Predict.shape)
# 	np.save(pred_name, Predict)

# for nfile in range(10):
# 	print(nfile)
# 	pred_name = './predict/pred_' + str(nfile+1).rjust(4, '0') + '.mat'
# 	print(pred_name)
# 	Predict = Result[nfile, :, :, :, :]
# 	Predict = np.squeeze(Predict)
# 	# Predict = np.array(Predict)
# 	print(Predict.shape)
# 	sio.savemat(pred_name,{'pred': Predict})





